import React, { Component } from "react";
import { connect } from "react-redux";
import Todolist from "./components/Todolist";

const mapStateToProps = (state) => {
  // console.log(state);
  return {
    count: state.get("count"),
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    add() {
      dispatch({ type: "add" });
    },
    minus() {
      dispatch({ type: "minus" });
    },
  };
};

@connect(mapStateToProps, mapDispatchToProps)
class App extends Component {
  state = {};
  render() {
    return (
      <>
        <h2>redux配合immutable</h2>
        <button onClick={this.props.minus}>-</button>
        <span>{this.props.count}</span>
        <button onClick={this.props.add}>+</button>

        <hr />

        <Todolist />
      </>
    );
  }
}

export default App;
